#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b); 
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,m;
		scanf("%d %d",&m,&n);
		if(m<n) swap(n,m);
// 		cout<<gcd(m,n);
		if(gcd(m,n)==1) cout<<"NO"<<'\n';
		else  cout<<"YES"<<'\n';
	}

	return 0;
}

